#ifndef _DOT_SORT_LEVEL_LOADER_VECTOR_LEVEL_LOADER_HPP_
#define _DOT_SORT_LEVEL_LOADER_VECTOR_LEVEL_LOADER_HPP_

#include <cstdint>
#include <vector>

#include <DotSort/Level.hpp>
#include <DotSort/LevelLoader/LevelLoader.hpp>


class VectorLevelLoader : public LevelLoader
{
	private:
		const uint8_t tubeSize;
		const uint8_t tubeCount;
		const std::vector<std::vector<uint8_t>>& dots;

	public:
		VectorLevelLoader(uint8_t tubeSize, uint8_t tubeCount, const std::vector<std::vector<uint8_t>>& dots)
			: tubeSize(tubeSize)
			, tubeCount(tubeCount)
			, dots(dots)
		{}

		virtual Level* operator()() const
		{
			Level* level = new Level(tubeSize, tubeCount);

			for(size_t i = 0; i < this->tubeCount; ++i)
			{
				auto tube = this->dots[i];

				for(auto dot : tube)
				{
					this->getTube(level, i).push(dot);
				}
			}

			return level;
		}
};

#endif
